package com.study;

import com.study.entity.Location;
import com.study.repository.LocationRepository;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;

/**
 * https://www.cnblogs.com/crazysquirrel/p/12804517.html
 * https://www.cnblogs.com/mizersy/p/10698409.html
 */

@SpringBootApplication
public class Springh2Application {


	public static void main(String[] args) {
		Starters.startH2Server();
		SpringApplication.run(Springh2Application.class, args);
	}

	@Bean
	InitializingBean saveData(LocationRepository repo) {
		return () -> {
			repo.save(new Location(1L, "1", 38.998064, 117.317267, ""));
			repo.save(new Location(2L, "2", 38.997793, 117.317069, ""));
			repo.save(new Location(3L, "3", 38.998006, 117.317101, ""));
			repo.save(new Location(4L, "4", 38.997814, 117.317332, ""));
		};
	}


}
